<template>
  <div class="list-container">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column type="index" :index="indexMethod" label="序号"></el-table-column>
      <el-table-column prop="subjectName" label="学科名称"> </el-table-column>
      <el-table-column prop="creatorID" label="创建者"></el-table-column>
      <el-table-column prop="addDate" label="创建日期" width="150">
        <template slot-scope="scope">
          <div class="text">
            {{ parseTime(new Date(scope.row.addDate)) }}
          </div>
        </template>
      </el-table-column>
       <el-table-column label="前台是否显示">
        <template slot-scope="scope">
          <div>{{ scope.row.isFrontDisplay === 1 ? '是' : '否' }}</div>
        </template>
       </el-table-column>
      <el-table-column prop="twoLevelDirectory" label="二级目录"></el-table-column>
      <el-table-column prop="tags" label="标签"></el-table-column>
      <el-table-column prop="totals" label="题目数量"></el-table-column>
      <el-table-column fixed="right" label="操作" width="290">
        <template slot-scope="scope">
          <div class="text">
            <el-button @click="handleClick(scope.row)" type="text" size="small">学科分类</el-button>
            <el-button type="text" size="small" @click="handleClickFn(scope.row)">学科标签</el-button>

            <el-button type="text" size="small" @click="checkFn(scope.row)">修改</el-button>
            <el-button type="text" size="small" @click="deleteFn(scope.row)">删除</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { parseTime } from '@/utils'
export default {
  name: 'subject-list',
  props: {
    tableData: {
      type: Array,
      required: true
    },
    isShow: {
      type: Boolean
    }
  },
  methods: {
    parseTime: parseTime,
    indexMethod (index) {
      return index + 1
    },
    checkFn (value) {
      this.$emit('onChange', value)
      this.$emit('input', true)
    },
    deleteFn (value) {
      this.$emit('delete', value)
    },
    handleClick (value) {
      this.$router.push({
        path: 'directorys',
        query: {
          id: value.id,
          name: value.subjectName
        }
      })
    },
    handleClickFn (value) {
      this.$router.push({
        path: 'tags',
        query: {
          id: value.id,
          name: value.subjectName
        }
      })
    }
  }
}
</script>
